home *** CD-ROM | disk | FTP | other *** search
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- 3D Graphics Programming Series
- ~3DGPS~
- ------------------------------
- Trainer #1
- Intro to 3D Graphics
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
- Welcome to trainer #1 of the 3D Graphics Programming Series!
-
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
-
- Hello! I am going to make a series of trainers to teach
- people the basics and the math involed in doing 3D graphics
- programming! As of yet, I have not seen this type of series
- exclusively on 3D graphics. I am going to start with the basics,
- and move on from there. So, be sure to stay tuned!
-
- As Always... you can reach me at nielsen@usinternet.com or
- as _mIkE on the Undernet in #mode13h - hope ta see ya! :)
-
- -=-=-=-=-=-=-=-=-=-=-=-
- Intro to 3D Graphics:
-
- 3D - Three dimensions... what does it mean for a graphics
- programmer? Well, working in 3D is a bit more difficult then
- standard 2D.. but with some tricks and a little help from me, it
- can all be done in no time!
-
- The 3D coordinate system is the same as the standard 2D
- cartesian system except with a Z-axis added on. The added z
- coordinate defines the depth of the object on the axis. In other
- words... it defines how close or how far the object is away from
- the viewer. The 3D coordinate system looks as follows:
-
- (always in my best acsii art)
-
- (+y) (+z into the monitor)
- | /
- | /
- | /
- (-x) ________|/________ (+x)
- /|(0,0,0)
- / |
- / |
- / |
- (-z toward eye)(-y)
-
-
- If the axis is centered in the middle of the screen, as it
- should be... the +z goes back, or away from the viewer, and the
- -z gets closer. This meaning that the object (in perspective)
- gets larger as it gets closer to the viewer, and smaller as it
- gets farther away.
-
- Ok, so I said the axis should be centered in the middle of the
- screen. It doesn't hafta be done this way, but it should be, so
- that it is more true in terms of the negative coordinates.
- Normally, if your x or y value is less than 0.. it is off the
- screen. But with the added z-axis in 3D, you don't want the
- origin to be centered in the upper left corner. So, we just
- offset the coordinates to center them, before we draw the image
- onto the screen. This allows for negative x and y values to be
- shown on the screen. Also, with the cartesian coordinate system,
- the y value is flipped compared to the screen. So, all we need
- to do is flip the y value, so the positive y values are above the
- axis, as they should be.
-
-
- (mode 13h)
- (0,0) ___________________ (319,0)
- | (+y) (+z) |
- | | / |
- |(-x) ____|/___ (+x)|
- | /|(0,0,0) |
- | / | |
- (0,199) |__(-z)__(-y)_______| (319,199)
-
-
- (ex..)
- halfscreenwidth = 160
- halfscreenheight = 100
- drawpoint(halfscreenwidth + x, halfscreenheight - y)
-
- In the above diagram, the origin is centered in the center of
- the screen, as described above, and the +y values are above the
- axis.
-
- Now, lets talk about the distance from the screen to your eye.
- This is very important also, for acurate 3D... as it defines how
- far you are from the origin and any object on the screen.
- Generally, the distance value should be about half the screen
- height (in pixels). But this can vary, depending on the type of
- perspective that is desired. Be sure to play around with this
- value. We will go more in-depth with this later.
- ยบ
-
- -=-=-=-=-=-=-=-=-=-=-=-
-
- Well, that wraps up this installment of the 3DGPS.. be sure
- to be tuned in for the next one...
-
- ------------------
- #2
- Points in 3D Space
- ------------------
-
- -=-=-=-=-=-=-=-=-=-=-=-=-
- These trainers were designed to
- aid those interested in doing 3D
- graphics programming, and as a
- reference for anyone in need.
- If you feel that any info given
- here is false in any way, or you
- have any comments whatsoever,
- please e-mail me :)
- -=-=-=-=-=-=-=-=-=-=-=-=-
- nielsen@usinternet.org
-
-